package list;

import com.google.common.base.Joiner;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author
 * @Title: TestJoin
 * @Description:
 * @date 2022/8/25 2:14 下午
 */
public class TestMax {

    /**
     * 拼接list
     */
    @Test
    public void test1(){
        Pojo p1 = new Pojo();
        Pojo p2 = new Pojo();
        Pojo p3 = new Pojo();
        p1.setAge(1L);
        p1.setName("1L");
        p2.setAge(2L);
        p2.setName("2L");
        p3.setAge(3L);
        p3.setName("3L");
        List<Pojo> list = new ArrayList<>();
        list.add(p1);
        list.add(p2);
        list.add(p3);
        Pojo pojo = list.stream().max(Comparator.comparing(e->e.getAge())).orElse(null);
        System.out.println(pojo);
    }



    public class Pojo{
        String name;
        Long age;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Long getAge() {
            return age;
        }

        public void setAge(Long age) {
            this.age = age;
        }

        @Override
        public String toString() {
            return "Pojo{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }

}
